var t = require("../../../@babel/runtime/helpers/objectSpread2"), a = getApp();

Page({
    data: {
        reason: "",
        photosize: 3145728,
        fileList: [],
        imgList: [],
        sendStatus: !1
    },
    onLoad: function(t) {},
    afterRead: function(e) {
        var i = this, n = e.detail.file, s = a.getNetAddresss("upload.uploadPic");
        wx.uploadFile({
            url: s,
            filePath: n.url,
            name: "file",
            formData: null,
            success: function(a) {
                var e = JSON.parse(a.data), s = i.data.fileList, o = void 0 === s ? [] : s;
                o.push(t(t({}, n), {}, {
                    url: e.data.img_url
                })), i.data.imgList.push(e.data.img_url), i.setData({
                    fileList: o
                });
            }
        });
    },
    bindinput: function(t) {
        this.setData({
            reason: t.detail.value
        });
    },
    ondelete: function(t) {
        this.data.imgList.splice(t.detail.index, 1), this.data.fileList.splice(t.detail.index, 1);
    },
    send: function() {
        var t = this;
        if ("" != this.data.reason) {
            if (!this.data.sendStatus) {
                this.setData({
                    sendStatus: !0
                });
                var e = a.getNetAddresss("plugin.luck-draw.frontend.index.complaint");
                a._postNetWork({
                    url: e,
                    data: {
                        activity_id: this.options.id,
                        reason: this.data.reason,
                        image: this.data.imgList
                    },
                    success: function(a) {
                        var e = a.data;
                        1 == e.result ? (t.data.sendStatus = !1, wx.showToast({
                            title: e.msg,
                            duration: 1e3,
                            icon: "none"
                        }), setTimeout(function() {
                            wx.navigateBack({
                                delta: 1
                            });
                        }, 1e3)) : (t.data.sendStatus = !1, wx.showToast({
                            title: e.msg,
                            duration: 1e3,
                            icon: "none"
                        }));
                    },
                    fail: function(a) {
                        t.data.sendStatus = !1, console.log(a.msg);
                    }
                });
            }
        } else wx.showToast({
            title: "请描述投诉的内容",
            duration: 1e3,
            icon: "none"
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});